<?php
class Cl_Bbs extends WdkClass 
{
	protected
		/******************************************************/
		//	원본 테이블 정보
		/******************************************************/
		$bbs_seq			= 0			,	//
		$bbs_id				= ''		,	//	
		$bbs_name			= ''		,	//	
		$bbs_header			= ''		,	//	
		$bbs_footer			= ''		,	//	
		$bbs_listsize		= 15		,	//	
		$bbs_pagesize		= 10		,	//	
		$bbs_file_flag		= 'F'		,	//	
		$bbs_file_num		= 1			,	//	
		$bbs_file_size		= 2			,	//	
		$bbs_file_type		= '*'		,	//	
		$bbs_skin			= 'default'	,	//	
		$bbs_category_flag	= 'F'		,	//	
		$bbs_comment_flag	= 'T'		,	//	
		$bbs_recommend_flag	= 'F'		,	//		
		$bbs_use_flag		= 'T'		,	//		
		$bbs_secure_flag	= 'T'		,	//	
		$bbs_captcha_flag	= 'T'		,	//	
		$bbs_insert_time	= 0			,	//	
		$bbs_del_flag		= 'F'		;	//	
		/******************************************************/
		//	추가 정보
		/******************************************************/
	
	/**
	 * 	
	 */
	function __construct()
	{
		parent::__construct();
		self::getDbo();
	}
	
	/**
	 *	
	 */
	public function __init($data)
	{
		parent::__init($data);
		self::dformat();
	}
	
	/**
	 *	
	 */
	public function load($bbs_seq)
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		self::__init($dbo->cLoad($bbs_seq));
	}
	
	/**
	 *	
	 */
	public function dformat()
	{
		
	}
	
	/**
	 * 
	 */
	public function autoUpdate($log='')
	{
		if((int)$this->bbs_seq > 0)
		{
			$this->update($log);
		}
		else
		{
			$this->insert($log);
		}
	}
	
	/**
	 *	
	 */
	public function insert($log='Insert')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		
		$this->bbs_insert_time	= time();
		$this->bbs_del_flag		= 'F';
		
		$data = array(	'bbs_id'				=>	$this->bbs_id,
						'bbs_name'				=>	$this->bbs_name,
						'bbs_header'			=>	$this->bbs_header,
						'bbs_footer'			=>	$this->bbs_footer,
						'bbs_listsize'			=>	$this->bbs_listsize,
						'bbs_pagesize'			=>	$this->bbs_pagesize,
						'bbs_file_flag'			=>	$this->bbs_file_flag,
						'bbs_file_num'			=>	$this->bbs_file_num,
						'bbs_file_size'			=>	$this->bbs_file_size,
						'bbs_file_type'			=>	$this->bbs_file_type,
						'bbs_skin'				=>	$this->bbs_skin,
						'bbs_category_flag'		=>	$this->bbs_category_flag,
						'bbs_comment_flag'		=>	$this->bbs_comment_flag,
						'bbs_recommend_flag'	=>	$this->bbs_recommend_flag,
						'bbs_use_flag'			=>	$this->bbs_use_flag,
						'bbs_secure_flag'		=>	$this->bbs_secure_flag,
						'bbs_captcha_flag'		=>	$this->bbs_captcha_flag,
						'bbs_insert_time'		=>	$this->bbs_insert_time,
						'bbs_del_flag'			=>	$this->bbs_del_flag
					);
		$this->bbs_seq = $dbo->insert($data);
		$this->backup($log);
	}
	
	/**
	 * 
	 */
	public function update($log='update')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		
		$data = array(	'bbs_name'				=>	$this->bbs_name,
						'bbs_header'			=>	$this->bbs_header,
						'bbs_footer'			=>	$this->bbs_footer,
						'bbs_listsize'			=>	$this->bbs_listsize,
						'bbs_pagesize'			=>	$this->bbs_pagesize,
						'bbs_file_flag'			=>	$this->bbs_file_flag,
						'bbs_file_num'			=>	$this->bbs_file_num,
						'bbs_file_size'			=>	$this->bbs_file_size,
						'bbs_file_type'			=>	$this->bbs_file_type,
						'bbs_skin'				=>	$this->bbs_skin,
						'bbs_category_flag'		=>	$this->bbs_category_flag,
						'bbs_comment_flag'		=>	$this->bbs_comment_flag,
						'bbs_recommend_flag'	=>	$this->bbs_recommend_flag,
						'bbs_use_flag'			=>	$this->bbs_use_flag,
						'bbs_secure_flag'		=>	$this->bbs_secure_flag,
						'bbs_captcha_flag'		=>	$this->bbs_captcha_flag
					);
		$dbo->update($data, array("bbs_seq = ".$this->bbs_seq));
		$this->backup($log);
	}
	
	/**
	 * 
	 */
	public function delete($log='delete')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		$dbo->delete(array("bbs_seq = ".$this->bbs_seq));
		$this->backup($log);
	}
	
	/**
	 *	
	 */
	private function backup($log='')
	{
// 		/*------------------------------------------------------------*/
// 		$dbo = self::getDbo();
// 		/*------------------------------------------------------------*/
// 		$dbo->log($this->user_seq, $log, $this->backup_data);
	}
	
	/**
	 * 
	 */
	public function getDbo()
	{
		return Wdk::model(substr(__CLASS__, 3));
	}
}